/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package sonia.golf.util;

//~--- non-JDK imports --------------------------------------------------------

import android.util.Log;

//~--- JDK imports ------------------------------------------------------------

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import sonia.golf.StrokeCounter;

/**
 *
 * @author Sebastian Sdorra
 */
public class Util
{

  /**
   * Method description
   *
   *
   * @param closeable
   */
  public static void close(Closeable closeable)
  {
    if (closeable != null)
    {
      try
      {
        closeable.close();
      }
      catch (IOException ex)
      {
        Log.w(StrokeCounter.LOG_TAG, ex.getMessage(), ex);
      }
    }
  }

  /**
   * Method description
   *
   *
   * @param input
   *
   * @return
   */
  public static BufferedReader createReader(InputStream input)
  {
    return new BufferedReader(new InputStreamReader(input));
  }

  //~--- get methods ----------------------------------------------------------

  /**
   * Method description
   *
   *
   * @param value
   *
   * @return
   */
  public static boolean isEmpty(String value)
  {
    return (value == null) || (value.trim().length() == 0);
  }

  /**
   * Method description
   *
   *
   * @param value
   *
   * @return
   */
  public static boolean isNotEmpty(String value)
  {
    return (value != null) && (value.trim().length() > 0);
  }
}
